package descentFly.away3D4.action
{
	import away3d.containers.ObjectContainer3D;
	
	import descentFly.df_spaceObject;
	
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	
	public class df_modelActions extends df_spaceObject {
		private var _actions	: Array;
		public function df_modelActions(aList: Array, a_model: ObjectContainer3D) {
			super();
			_actions = new Array();
			appendList(aList, a_model);
		}
		
		public function appendList(a_actions: Array, a_model: ObjectContainer3D): void {
			a_actions.forEach(function(action: Object, i: int, arr: Array): void {
				_actions.push(new (action.Class)(action, a_model));
			});			
		}
		
		public function beginAction(actionName: String, startParam: Object=null): void {
			if (_actions) {
				_actions.forEach(function(action: df_action, i: int, arr: Array): void {
					if (action.name == actionName) action.start(startParam);
				});
			}
		}
		
		override public function dispose(): void {
			_actions.forEach(function(action: df_action, i: int, arr: Array): void {
				action.dispose();
			});
			_actions.splice(0);
			super.dispose();
		}
	}
}